// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Result.java

package com.vandagroup.common.util;

import com.vandagroup.common.bean.BaseBean;
import com.vandagroup.common.bo.ESSBean;
import java.util.Vector;
import org.apache.struts.validator.ValidatorForm;

public class Result
{

    protected String columnNames;
    public BaseBean baseBeans[];
    public ValidatorForm forms[];
    public static final int DEFAULT_PAGE_SIZE = 20;
    protected Vector result;
    protected ESSBean beans;
    protected int counter;
    protected int startPosition;
    protected int resultSize;

    public Result()
    {
        columnNames = null;
        baseBeans = null;
        forms = null;
        result = new Vector();
        beans = null;
        counter = 0;
        startPosition = 0;
        resultSize = 20;
    }

    public Result(int start, int resultSize)
    {
        columnNames = null;
        baseBeans = null;
        forms = null;
        result = new Vector();
        beans = null;
        counter = 0;
        startPosition = 0;
        this.resultSize = 20;
        startPosition = start;
        this.resultSize = resultSize;
    }

    public ESSBean getBeans()
    {
        return beans;
    }

    public int getCounter()
    {
        return counter;
    }

    public int getCurrentPageNo()
    {
        if(resultSize <= 0)
            return 1;
        else
            return 1 + ((startPosition + resultSize) - 1) / resultSize;
    }

    public int getMaxPageNo()
    {
        if(resultSize <= 0)
            return 1;
        else
            return ((counter + resultSize) - 1) / resultSize;
    }

    public int getResultSize()
    {
        return resultSize;
    }

    public int getStartPosition()
    {
        return startPosition;
    }

    public int getStartPosition(int pageNo)
    {
        if(pageNo < 1)
        {
            return 0;
        } else
        {
            int start = resultSize * (pageNo - 1);
            startPosition = start;
            return start;
        }
    }

    public static int getStartPosition(int pageNo, int resultSize)
    {
        return resultSize * (pageNo - 1);
    }

    public void setBeans(ESSBean newBeans)
    {
        beans = newBeans;
    }

    public void setCounter(int newCounter)
    {
        counter = newCounter;
    }

    public void setResultSize(int newResultSize)
    {
        resultSize = newResultSize;
    }

    public void setStartPosition(int newStartPosition)
    {
        startPosition = newStartPosition;
    }

    public ESSBean[] getAllBeans()
    {
        if(beans == null)
            return null;
        else
            return beans.getBeans();
    }

    public int getPageSize()
    {
        if(beans == null)
            return 0;
        else
            return beans.getBeans().length;
    }

    public boolean exist(ESSBean checkBean)
    {
        boolean existed = false;
        if(beans == null || checkBean == null)
            return false;
        ESSBean beansList[] = beans.getBeans();
        for(int i = 0; i < beansList.length; i++)
        {
            if(!beansList[i].equals(checkBean))
                continue;
            existed = true;
            break;
        }

        return existed;
    }

    public Vector getResult()
    {
        return result;
    }

    public void setResult(Vector result)
    {
        this.result = result;
    }

    public BaseBean[] getBaseBeans()
    {
        return baseBeans;
    }

    public void setBaseBeans(BaseBean baseBeans[])
    {
        this.baseBeans = baseBeans;
    }

    public ValidatorForm[] getForms()
    {
        return forms;
    }

    public void setForms(ValidatorForm forms[])
    {
        this.forms = forms;
    }

    public String getColumnNames()
    {
        return columnNames;
    }

    public void setColumnNames(String columnNames)
    {
        this.columnNames = columnNames;
    }
}
